package br.com.ruidobrasil.util;

import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.Iterator;

public class FileFilter implements FilenameFilter {

	private String _employeeID = "";
	private ArrayList _imageTypes;
	
	public boolean accept(File dir, String name) {
		
		boolean startsWith = false;
		boolean endsWith = false;
		startsWith = name.startsWith(getEmployeeID());
		Iterator iterator = getImageTypes().iterator();
		
		while (iterator.hasNext()) {
			if (name.toLowerCase().endsWith((String) iterator.next())) {
				endsWith = true;
				break;
			}
		}
		return startsWith && endsWith;
	}
	
	public String getEmployeeID(){ 
		return _employeeID; 
	} 
	
	public void setEmployeeID(String value){ 
		_employeeID = value; 
	} 
	
	public ArrayList getImageTypes(){ 
		return _imageTypes; 
	} 
	
	public void setImageTypes(ArrayList value){ 
		_imageTypes = value; 
	}
}
